package com.github.houkunlin.extension;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiTreeChangeEvent;
import com.intellij.psi.PsiTreeChangeListener;
import org.jetbrains.annotations.NotNull;

/**
 * @Author tanqi
 * @Description TODO 文件改动同步,减少手动刷新
 * @Date 2022/10/13 11:02
 * @Version 1.0
 */
public class PsiTreeListenerImpl implements PsiTreeChangeListener {

    private static final Logger LOG = Logger.getInstance(PsiTreeListenerImpl.class);

    @Override
    public void beforeChildAddition(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void beforeChildRemoval(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void beforeChildReplacement(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void beforeChildMovement(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void beforeChildrenChange(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void beforePropertyChange(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void childAdded(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void childRemoved(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void childReplaced(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void childrenChanged(@NotNull PsiTreeChangeEvent event) {
        PsiFile file = event.getFile();
        if(file != null){
            String fileName = file.getName();
            if("config.yml".equalsIgnoreCase(fileName)){

            }
        }
        LOG.debug(event.toString());
    }

    @Override
    public void childMoved(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }

    @Override
    public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
        LOG.debug(event.toString());
    }
}
